<template>
	<view class="list" v-if="Object.keys(playlist).length>0">
		<view class="fixbg" :style="{ 'background-image': 'url(' + playlist.coverImgUrl + ')' }"></view>
		<musichead title="歌单" :icon="true" color="white"></musichead>
		<view class="container" v-show="!isLoading">
			<scroll-view scroll-y="true">
				<view class="list-head">
					<view class="list-head-img">
						<image :src="playlist.coverImgUrl" mode=""></image>
						<text class="iconfont iconyousanjiao">{{ playlist.playCount | formatCount }}</text>
					</view>
					<view class="list-head-text">
						<view class="">{{ playlist.name }}</view>
						<view class="">
							<image :src="playlist.creator.avatarUrl" mode=""></image>
							{{ playlist.creator.nickname }}
						</view>
						<view class="">{{ playlist.description }}</view>
					</view>
				</view>
				<!-- #ifdef MP-WEIXIN -->
				<button class="list-share" open-type="share">
					<text class="iconfont iconicon-"></text>
					分享给微信好友
				</button>
				<!-- #endif -->
				<view class="list-music">
					<view class="list-music-head">
						<text class="iconfont iconbofang1"></text>
						<text>播放全部</text>
						<text>(共{{ playlist.trackCount }}首)</text>
					</view>
					<view class="list-music-item" v-for="(item, index) in playlist.tracks" :key="index" @tap="handleToDetail(item.id)">
						<view class="list-music-top">{{ index + 1 }}</view>
						<view class="list-music-song">
							<view class="">{{ item.name }}</view>
							<view class="">
								<image v-if="privileges[index].flag > 60 && privileges[index].flag < 70" src="../../../static/dujia.png" mode=""></image>
								<image v-if="privileges[index].maxbr == 999000" src="../../../static/sq.png" mode=""></image>
								{{ item.ar[0].name }} - {{ item.name }}
							</view>
						</view>
						<text class="iconfont iconbofang"></text>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
import '@/common/iconfont.css';
import musichead from '@/components/controlled/musichead/musichead.vue';
import { list } from '@/common/api.js';
import {mapMutations} from "vuex"
export default {
	components: { musichead },
	data() {
		return {
			playlist: {},
			privileges: [],
			isLoading: true
		};
	},
	async onLoad(options) {
		uni.showLoading({
			title: '加载中...'
		});
		const res = await list({ id: options.listId });
		if (res.data.code !== 200) return;
		this.playlist = res.data.playlist;
		this.privileges = res.data.privileges;
		this.INIT_TOPLISTIDS(res.data.playlist.trackIds);
		this.isLoading = false;
		uni.hideLoading();
		// console.log(this.playlist);
	},
	methods:{
		...mapMutations(['INIT_TOPLISTIDS']),
		handleToDetail(songId){
			uni.navigateTo({
				url:'/pagesDetail/pages/detail/detail?songId='+songId
			})
		}
	}
};
</script>

<style lang="less" scoped>
.list {
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	.list-head {
		display: flex;
		margin: 30rpx;
		.list-head-img {
			width: 264rpx;
			height: 264rpx;
			border-radius: 30rpx;
			overflow: hidden;
			position: relative;
			margin-right: 42rpx;
			image {
				width: 100%;
				height: 100%;
			}
			text {
				position: absolute;
				right: 8rpx;
				top: 8rpx;
				color: white;
				font-size: 26rpx;
			}
		}
		.list-head-text {
			flex: 1;
			color: #fff;
			view {
				&:nth-of-type(1) {
					color: white;
					font-size: 34rpx;
				}
				&:nth-of-type(2) {
					display: flex;
					margin: 20rpx 0;
					font-size: 24rpx;
					align-items: center;
					image {
						width: 54rpx;
						height: 54rpx;
						border-radius: 50%;
						margin-right: 14rpx;
					}
				}
				&:nth-of-type(3) {
					line-height: 34rpx;
					font-size: 22rpx;
				}
			}
		}
	}
	.list-share {
		width: 330rpx;
		height: 74rpx;
		margin: 0 auto;
		background: rgba(0, 0, 0, 0.4);
		border-radius: 37rpx;
		color: white;
		text-align: center;
		line-height: 74rpx;
		font-size: 28rpx;
		text {
			margin-right: 16rpx;
		}
	}
	.list-music {
		background: white;
		border-top-left-radius: 50rpx;
		border-top-right-radius: 50rpx;
		margin-top: 40rpx;
		overflow: hidden;
		.list-music-head {
			height: 50rpx;
			margin: 30rpx 0 70rpx 22rpx;
			text {
				&:nth-of-type(1) {
					height: 50rpx;
					font-size: 50rpx;
				}
				&:nth-of-type(2) {
					margin: 0 10rpx 0 26rpx;
					font-size: 30rpx;
				}
				&:nth-of-type(3) {
					color: #b2b2b2;
					font-size: 26rpx;
				}
			}
		}
		.list-music-item {
			display: flex;
			margin: 0 32rpx 66rpx 46rpx;
			align-items: center;
			color: #959595;
			.list-music-top {
				width: 100rpx;
				font-size: 50rpx;
				line-height: 50rpx;
				text-align: center;
			}
			.list-music-song {
				flex: 1;
				view {
					&:nth-of-type(1) {
						font-size: 28rpx;
						color: black;
						width: 70vw;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
					&:nth-of-type(2) {
						font-size: 20rpx;
						width: 70vw;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
						image {
							width: 32rpx;
							height: 20rpx;
							margin-right: 10rpx;
							flex-shrink: 0;
						}
					}
				}
			}
			text {
				font-size: 50rpx;
				color: #c7c7c7;
			}
		}
	}
}
</style>
